import request from '@/utils/request'

// 查询进货订单列表
export function listPurchase(query) {
  return request({
    url: '/purchase/purchase/list',
    method: 'get',
    params: query
  })
}

// 查询进货订单详细
export function getPurchase(phId) {
  return request({
    url: '/purchase/purchase/' + phId,
    method: 'get'
  })
}

// 新增进货订单
export function addPurchase(data) {
  return request({
    url: '/purchase/purchase',
    method: 'post',
    data: data
  })
}

// 修改进货订单
export function updatePurchase(data) {
  return request({
    url: '/purchase/purchase',
    method: 'put',
    data: data
  })
}

// 删除进货订单
export function delPurchase(phId) {
  return request({
    url: '/purchase/purchase/' + phId,
    method: 'delete'
  })
}

// 获取编码
export function getCode(code) {
  return request({
    url: '/purchase/purchase/getcode?code=' + code,
    method: 'post'
  })
}
// 下拉列表
export function selectAllSysDept() {
  return request({
    url: '/purchase/purchase/selectAllSysDept',
    method: 'get'
  })
}
// 下拉子列表
export function selectAllSysDeptByID(parent) {
  return request({
    url: '/purchase/purchase/selectAllSysDeptByID?deptid='+parent,
    method: 'get'
  })
}

//根据部门id 查用户
export function selectUserById(deptid) {
  return request({
    url: '/purchase/purchase/selectUserById?deptid='+deptid,
    method: 'post',
  })
}

//审核
export function checkbyId(map) {
  return request({
    url: '/purchase/purchase/check',
    method: 'post',
    data:map
  })
}
//撤销
export function revokebyId(phid) {
  return request({
    url: '/purchase/purchase/revoke?phid='+phid,
    method: 'post',
  })
}

//查看进货订单详情
export function getInfo(phid) {
  return request({
    url: '/purchase/purchase/fileInfo?phcode='+phid,
    method: 'post',
  })
}

//进货退货单查询进货订单
export function selectPurchase(data) {
  return request({
    url: '/purchase/purchase/findOdPurchase',
    method: 'post',
    data: data
  })
}
//关闭单据
export function colseById(phid) {
  return request({
    url: '/purchase/purchase/colseById?phid='+phid,
    method: 'post',
  })
}
//根据进货单查看累计入库数量和创建时间
export function selectByPhCode(phCode) {
  return request({
    url: '/purchase/purchase/selectByPhCode?phCode='+phCode,
    method: 'get',
  })
}
